let localReject = (): void => {};

export default (promise: Promise<any>): Promise<any> => {
  if (localReject) {
    localReject();
  }

  return new Promise((resolve, reject): void => {
    localReject = reject;
    promise
      .then((res): void => resolve(res))
      .catch((error): void => reject(error));
  });
};
